<?php


namespace App\Models;


class Attachment extends Model
{
    protected $table = 'attachments';

    const TYPE = [
        'image' => 0,
        'audio' => 1,
        'video' => 2
    ];
    
    // ============= scope ==========
    public function scopeOfType($query, $type)
    {
        return $query->where('type', $type);
    }

    // ============= field ==========
    public function setName($name)
    {
        $this->name = $name;
    }

    public function getName()
    {
        return $this->name;
    }


    public function setUri($uri)
    {
        $this->uri = $uri;
    }

    public function getUri()
    {
        return $this->uri;
    }


    public function setType($type)
    {
        $this->type = $type;
    }

    public function getType()
    {
        return $this->type;
    }

    public function setExt($ext)
    {
        $this->ext = $ext;
    }

    public function getExt()
    {
        return $this->ext;
    }

    public function setSize($size)
    {
        return $this->size = $size;
    }

    public function setProperties($properties)
    {
        $this->properties = json_encode($properties);
    }

    public function getProperties()
    {
        return json_decode($this->properties, true);
    }
}